<template>
	<view class="theme-item">
		<view class="box" v-if="!isMore" @click="gotoDetail">
			<image class="pic" :src="info.picurl" mode="aspectFill"></image>
			<view class="mask">{{ info.name }}</view>
			<view class="tab">{{ compareTimestamp(info.updateTime) }}天前更新</view>
		</view>
		
		<navigator url="/pages/classify/classify" open-type="switchTab" class="box more" v-else>
			<image class="pic" src="@/static/images/more.jpg" mode="aspectFill"></image>
			<view class="mask">
				<uni-icons type="more-filled" size="34" color="#fff"></uni-icons>
				<view class="text">更多</view>
			</view>
		</navigator>
	</view>
</template>

<script setup>
import { compareTimestamp } from '@/utils/common.js'

const props = defineProps({
	info: {
		type: Object,
		default: () => {
			return {
				name: '壁纸',
				picurl: 'https://i.111666.best/image/vsRuq5AGowWj89SvKMCK9R.jpg',
				updateTime: Date.now() - (1000 * 60 * 60 * 24 * 7)
			}
		}
	},
	isMore: {
		type: Boolean,
		default: false
	}
})

const gotoDetail = () => uni.navigateTo({ url: `/pages/class-list/class-list?id=${props.info._id}&name=${props.info.name}`})

</script>

<style lang="scss" scoped>
.theme-item {
	
	& > .box {
		height: 340rpx;
		border-radius: 10rpx;
		overflow: hidden;
		position: relative;
		.pic {
			width: 100%;
			height: 100%;
		}
		.mask {
			width: 100%;
			height: 70rpx;
			position: absolute;
			bottom: 0;
			left: 0;
			background: rgba(0, 0, 0, .2);
			color: #fff;
			font-size: 30rpx;
			text-align: center;
			line-height: 70rpx;
			backdrop-filter: blur(20rpx);
			font-weight: 600;
		}
		.tab {
			position: absolute;
			top: 0;
			left: 0;
			background: rgba(250, 129, 90, .7);
			color: #fff;
			backdrop-filter: blur(20rpx);
			font-size: 22rpx;
			padding: 6rpx 14rpx;
			border-radius: 0 0 20rpx 0;
			transform: scale(.8);
			transform-origin: left top;
		}
	}
	.box.more {
		.mask {
			width: 100%;
			height: 100%;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
		}
		.text {
			font-size: 28rpx;
			
		}
	}
}
</style>